using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace RegExpTester
{
	public partial class RegExpTester : Form
	{
		public RegExpTester() {
			InitializeComponent();
			this.tbRegEx.TextChanged += new EventHandler(textChanged);
			this.tbText.TextChanged += new EventHandler(textChanged);
		}

		void textChanged(object sender, EventArgs e) {
			tbMatches.Clear();
			try
			{
				MatchCollection col = Regex.Matches(this.tbText.Text, this.tbRegEx.Text);
				foreach (Match m in col)
				{
					tbMatches.AppendText(m.ToString());
					tbMatches.AppendText(Environment.NewLine);
				}
			} catch (Exception ex) {
				tbMatches.AppendText("invalid pattern (" + ex.Message + ")");
			}
		}
	}
}